/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.repair.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.Query;
import org.springblade.modules.repair.dto.*;
import org.springblade.modules.repair.dto.plan.PlanOrderHomePage4SearchDTO;
import org.springblade.modules.repair.dto.plan.PlanOrderHomePageSearchDTO;
import org.springblade.modules.repair.dto.plan.offline.ByPlanOfflineDetailDTO;
import org.springblade.modules.repair.dto.plan.offline.ByPlanOfflineDetailDTO;
import org.springblade.modules.repair.dto.plan.PlanOrderHomePageSearchDTO;
import org.springblade.modules.repair.dto.statistical.by.CheckStatisticsPlanSimpleDTO;
import org.springblade.modules.repair.entity.MaintainPlanContent;
import org.springblade.modules.repair.vo.*;
import org.springblade.modules.repair.vo.plan.*;
import org.springblade.modules.repair.vo.plan.OfflineByPlanListVO;
import org.springblade.modules.repair.vo.plan.PlanContentElevatorVo;
import org.springblade.modules.repair.vo.plan.PlanOrderHomePageVO;
import org.springblade.modules.repair.vo.plan.OfflineByPlanListVO;
import org.springblade.modules.repair.vo.plan.PlanContentElevatorVo;
import org.springblade.modules.repair.vo.plan.PlanOrderHomePageVO;
import org.springblade.modules.repair.vo.plan.statistics.WxBuildingSimpleVO;
import org.springblade.modules.repair.vo.plan.statistics.WxElevatorSimpleVO;
import org.springblade.modules.repair.vo.plan.v2.MaintainPlanContentHomeListVo;
import org.springblade.modules.repair.vo.plan.v2.PlanUserInfoVo;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 维保任务表 服务类
 *
 * @author ysq
 * @since 2022-03-28
 */
public interface IMaintainPlanContentService extends BaseService<MaintainPlanContent> {

	/**
	 * 自定义分页
	 * @param planContentSearchDTO
	 * @return 数据集
	 */
	MaintainPlanContentHomeListVo selectMaintainPlanContentPage(PlanContentSearchDTO planContentSearchDTO);

	/**
	 * 获取首页数据2.0
	 * @param searchDTO
	 * @return
	 */
	IPage<PlanOrderHomePageVO> planOrderHomePage(PlanOrderHomePageSearchDTO searchDTO, IPage<PlanOrderHomePageVO> page);

	/**
	 * 获取首页数据3.0
	 * @param searchDTO
	 * @return
	 */
	IPage<PlanHomeDataVO> planOrderHomePageV3(PlanOrderHomePageSearchDTO searchDTO, IPage<PlanHomeDataVO> page);

	/**
	 * 获取首页数据4.0-角标统计
	 * @param planContentSearchDTO
	 * @return
	 */
	List<MaintainPlanContentTypeCountVo> planOrderHomeTypeStatistics(PlanOrderHomePage4SearchDTO planContentSearchDTO);

	/**
	 * 获取首页数据4.0
	 * @param searchDTO 搜索条件
	 * @param page 分页参数
	 * @return 分页结果
	 */
	IPage<PlanHomeV4DataVO> planOrderHomePageV4(PlanOrderHomePage4SearchDTO searchDTO, IPage<PlanHomeV4DataVO> page);

	/**
	 * 首页-我的任务4.0-已完成任务列表
	 * @param searchDTO
	 * @return
	 */
	List<PlanFinishOrderHomePageV4VO> planOrderHomeFinishPageV4(PlanOrderHomePage4SearchDTO searchDTO);

	/**
	 * 更新维保信息
	 * @param maintainPlanContent 更新内容
	 * @return 数据集
	 */
    boolean update(MaintainPlanContent maintainPlanContent);

	List<PlanTemplateVO> getPlanWorkItem(Long planId, Long tltId, Long templateId);

	Boolean planCommit(MaintainPlanContent planContent);

	Map<String, Object> getPlanLocationType(Long planId);

	HashMap<String,Object> selectPlanDetail(Long planId);

	/**
	 * 根据任务id保养位置信息
	 * @param planId 任务id
	 * @return 数据集
	 */
    List<String> getLocationTypeOfplanId(Long planId);

    List<Long> listUserPlan(Integer typeStatus, Long planId, Long userId);

	List<PlanTemplateContentVO> getPlanWorkItemList(Long planId);

	CheckPlanCountVO checkPlanCount(List<Long> toLongList, String startTime, String endTime);

    IPage<PlanDataPageVO> selectPlanList(CheckPlanPageQueryDTO queryDTO, IPage<PlanDataPageVO> page);

	IPage<PlanDataPageVO> selectScoreList(CheckPlanPageQueryDTO queryDTO, IPage<PlanDataPageVO> page);

	Long selectCheckPlanCount(CheckPlanPageQueryDTO queryDTO);

	Object elevatorPlanHistory(CheckPlanPageQueryDTO queryDTO, Query query);

    LastPlanVO selectElevatorLastPlan(Long elevatorId, Long planId);

	String getPlanTemplateName(Long planId);

	/**
	 * 根据工单id获取电梯位置信息
	 * @param planId
	 * @return
	 */
	ElevatorSimpleInfoVO getElevatorSimpleInfo(Long planId);

    int countCorrelationPlan(Long planId);

	/**
	 * 根据流程实例id查询工单
	 * @param processInstanceId
	 * @return
	 */
	MaintainPlanContent getMaintainPlanByProcessInstanceId(String processInstanceId);

	Object allElevatorPlanHistory(CheckPlanPageQueryDTO queryDTO, IPage<Object> page);

    HomePlanStatusCountVO selectUserPlanStatus(Long userId);

    HomePlanApproveCountVO selectUserPlanApprove(Long userId);

	HomePlanApplyCountVO selectUserPlanApply(Long userId);

    HomeDeptBuildingPlanCountVO selectDeptBuildingPlanCount(Long userId);

	HomeDeptBuildingPlanCountVO selectUserBuildingPlanCount(Long userId);

	/**
	 * 查询电梯任务历史-保养
	 * @param queryDTO
	 * @param page
	 * @return
	 */
	IPage<PlanDataPageVO> elevatorPlanHistoryBy(ByPlanHistoryDTO queryDTO, IPage<PlanDataPageVO> page);

	/**
	 * 查询电梯任务历史-维修
	 * @param queryDTO
	 * @param page
	 * @return
	 */
	IPage<MalFunctionPlanPageVO> elevatorPlanHistoryWx(WxPlanHistoryDTO queryDTO, IPage<MalFunctionPlanPageVO> page);

	/**
	 * 查询电梯任务历史-配件
	 * @param queryDTO
	 * @param page
	 * @return
	 */
	IPage<MalFunctionPlanPageVO> elevatorPlanHistoryPj(PjPlanHistoryDTO queryDTO, IPage<MalFunctionPlanPageVO> page);

	Map<String,Object> elevatorPlanHistoryFinishBy(ByPlanHistoryDTO queryDTO);

	Map<String,Object> elevatorPlanHistoryUnfinishedBy(ByPlanHistoryDTO queryDTO);

	Map<String,Object> elevatorPlanHistoryFinishWx(WxPlanHistoryDTO queryDTO);

	Map<String,Object> elevatorPlanHistoryUnfinishedWx(WxPlanHistoryDTO queryDTO);

	Map<String,Object> elevatorPlanHistoryFinishPj(PjPlanHistoryDTO queryDTO);

	Map<String,Object> elevatorPlanHistoryUnfinishedPj(PjPlanHistoryDTO queryDTO);

	SimpleElevatorPlanInfoDTO getSimpleElevatorPlanInfo(Long planId);

	/**
	 * 根据工单id获取用户的签到签退信息
	 * @param planId 工单id
	 * @return 数据集
	 */
	Map<String, List<PlanUserInfoVo>> getPlanUserInfo(Long planId);

	/**
	 * 保养工单维保签字完成后发送物业签字通知
	 * @param planId
	 */
	void sendEstateMsg(Long planId);

    Map<String,Object> selectPlanSimpleDetail(Long planId);

    List<MaintainPlanContent> listByUserDate(PlanCheckStatisticsQueryDTO queryDTO, List<Long> userIds);

    List<CheckStatisticsPlanSimpleDTO> listPlanExtByUserDate(PlanCheckStatisticsQueryDTO queryDTO, List<Long> userIds);


	/**
	 * 获取首页各种类型工单进行的数据统计
	 * @return 数据集
	 */
	List<PlanTypeStatisticVo>  getPlanTypeStatistic();


	/**
	 * 维修全列表排序逻辑更改
	 * @param queryDTO 查询DTO
	 * @param page 分页条件
	 * @return 分页结果
	 */
	IPage<MalFunctionPlanPageVO> elevatorPlanHistoryRepair(RepairPlanHistoryDTO queryDTO, IPage<MalFunctionPlanPageVO> page);

	/**
	 * 查询电梯任务历史-保养(旧版)
	 * @param queryDTO
	 * @param page
	 * @return
	 */
	IPage<PlanDataPageVO> elevatorPlanHistoryBySkip(ByPlanHistorySkipDTO queryDTO, IPage<PlanDataPageVO> page);

	/**
	 * 查询电梯任务历史-配件(旧版)
	 * @param queryDTO
	 * @param page
	 * @return
	 */
	IPage<MalFunctionPlanPageVO> elevatorPlanHistoryPjSkip(PjPlanHistorySkipDTO queryDTO, IPage<MalFunctionPlanPageVO> page);

	/**
	 * 根据当前用户及审核状态查询申请维修报障列表
	 * @param userId 当前用户id
	 * @param page 分页信息
	 * @param approveStatus 审核状态
	 * @return 当前用户申请维修列表
	 */
	IPage<MyApproveVO> getMyApproveList(Long userId, Integer approveStatus, IPage<MyApproveVO> page);

	Map<String,Object> getPlanAllowSign(Long planId);

	Boolean planDetailUpdate(MaintainPlanContent planContent);

	void updateElevatorStrategy(List<Long> elevatorIds);

	/**
	 * 电梯计划策略更新
	 * @param elevatorIds
	 * @param isUpdateOverdueDate 是否更新逾期时间
	 */
	void updateElevatorStrategy(List<Long> elevatorIds, boolean isUpdateOverdueDate);

	Boolean botSendMsg(Long planId, Integer isStop);
	/**
	 * 保养计划日历图
	 * @param calendarDataDTO
	 * @return
	 */
	Map<String, Map<String, Object>> maintainPlanCalendarData(MaintainPlanCalendarDataDTO calendarDataDTO);

	/**
	 * 获取日历工单数据下载
	 * @param calendarDataDTO
	 * @return
	 */
	String getDatePlanInfoListDownExcel(MaintainPlanCalendarDataDownDTO calendarDataDTO) throws IOException;

	/**
	 * 获取日历工单下载统计数
	 * @param calendarDataDTO
	 * @return
	 */
	int getDatePlanInfoListDownStatistics(MaintainPlanCalendarDataDownDTO calendarDataDTO);

	/**
	 * 保养计划日历列表明细统计
	 * @param calendarDataDTO
	 * @return
	 */
	PlanCalendarListStatisticsVO getPlanCalendarListStatistics(MaintainPlanCalendarDataDTO calendarDataDTO);

    List<PlanSimpleInfoDTO> listPlanSimpleByElevatorIds(PlanCheckStatisticsQueryDTO queryDTO, List<Long> elevatorIds, int typeStatus);

    List<WxBuildingSimpleVO> selectWxRepetitionBuildingSimpleByIds(List<Long> buildingIds, IPage<WxBuildingSimpleVO> page);

	List<WxElevatorSimpleVO> getElevatorSimpleAndWxPlan(List<Long> elevatorIds, PlanCheckStatisticsQueryDTO queryDTO);

	Map<String,Object> selectElevatorFilesAllPlan(Long elevatorId, String startDate, String endDate);

	Map<String,Object> selectElevatorFilesAllPlanWorkItem(Long elevatorId, Long partsId, String startDate, String endDate, Long floorStandIds);

	Map<String,Object> selectElevatorFilesByPlanWorkItem(Long elevatorId, Long partsId, String startDate, String endDate);

	Map<String,Object> selectElevatorFilesWxPlanWorkItem(Long elevatorId, Long partsId, String startDate, String endDate, Long floorStandIds);

	Map<String,Object> selectElevatorFilesPjPlanWorkItem(Long elevatorId, Long partsId, String startDate, String endDate, Long floorStandIds);

    List<PlanTemplateVO> workItemPreview(Long templateId, Long tltId);

	List<PlanDetailLocationTypeVO> getPlanLocationTypePreview(Long templateId);

    Boolean byOfflineUpdate(ByPlanOfflineDetailDTO dto);

	/**
	 * 离线保养缓存数据2.0
	 * @return
	 */
	List<OfflineByPlanListVO> getOfflineByPlanList();

	/**
	 * 离线保养缓存数据1.0
	 * @return
	 */
	List<PlanContentElevatorVo> getOldOfflineByPlanList();

    List<Long> getFromPlanIdByOwnId(Long planId);

    ElevatorRescueRobotSimpleVO getElevatorSimpleInfoByPlanId(Long planId);

    Map<String,Long> selectPlanUserOverdueCount();

	/**
	 * 救援大屏个人详情工单统计
	 * @param userIds
	 * @return
	 */
	List<MaintainPlanContent> screenUserPlanStatisticsList(List<Long> userIds);
}
